package booksManagement;

import java.util.*;

import exceptions.*;
import loansManagement.Loan;

import javax.persistence.*;

import org.hibernate.annotations.NaturalId;

import subscribersManagement.UtilsDate;

/**
 * @author        user
 */
@Entity
@DiscriminatorValue("DVD")
@Table(name="DVDs")
@NamedQuery(name="findAllDVDs", query="select d from DVD d")
public class DVD extends Media
{
	/*/**
   * @uml.property  name="isan"
   */
	/*@Column(name="isan")
	@NaturalId
	private String isan;*/
	
		
  	/**
  	 */
  public DVD(){
  	}
	
	public DVD( String title, Calendar editionDate, String isan) throws BadParametersException{
		super(title, editionDate);
		this.setIsan(isan);
		
	}
	
		
  	
  public DVD(String title, Calendar editionDate, String isan, int copyAmount)	throws BadParametersException {
 		super(title, editionDate, copyAmount);
 		this.setIsan(isan);
 	}
	/**
   * @return
   * @uml.property  name="isan"
   */
	@Column(name="isan")
	public String getIsan(){
		return 	this.isbn_isan;
	}
	
	/**
   * @param  isan
   * @uml.property  name="isan"
   */
	public void setIsan(String isan){
		if (isan==null) 
			throw new NullPointerException("null isan");
		this.isbn_isan=isan;
	}
	
	
	@Override
	/**
	 * Two  DVDs are the same if their isan is the same
	 */
	public boolean equals(Object DVD) {
		if (DVD == null)
			return false;
		DVD d = (DVD) DVD;

		if (d.isbn_isan == isbn_isan)
			return true;

		return false;
	}
	
	@Override
	public String toString() {
		return this.title + ", " + this.isbn_isan + ", " + UtilsDate.dateToString(editionDate.getTime()) + ", number of copies : " +this.copies.size();
	}

}
